package com.clerkq.FlvPlayer.ui
{
//	import caurina.transitions.Tweener;
	
	import com.library.core.IDisposable;
	import com.library.core.UIObject;
	
	import flash.display.Sprite;
	import flash.text.AntiAliasType;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	import gs.TweenLite;

	public class TitlePop extends UIObject implements IDisposable
	{
		private const WIDTH:Number = 480;
		private const HEIGHT:Number = 20;
		
		private var _titleTxt:TextField;
		private var _bg:Sprite;
		private var _bgMask:Sprite;
		
		public function TitlePop()
		{
			super();
			mouseEnabled = false;
			addBG();
			addText();
		}
		
		private function addBG():void{
			_bg = new Sprite();
			_bg.graphics.beginFill(0x000000, 0.3);
			_bg.graphics.drawRect(0,0,480,20);
			addChild(_bg);
			_bg.y = HEIGHT;
			
			_bgMask = new Sprite();
			_bgMask.graphics.beginFill(0x000000, 0.3);
			_bgMask.graphics.drawRect(0,0,WIDTH,HEIGHT);
			addChild(_bgMask);
			_bg.mask = _bgMask;
		}
		
		private function addText():void{
			
			var titleFmt:TextFormat = new TextFormat();
				titleFmt.font = "Arial";
				titleFmt.size = 11;
				titleFmt.color = 0xffffff;
				
			_titleTxt = new TextField();
			_titleTxt.defaultTextFormat = titleFmt;
			_titleTxt.selectable = false;
			_titleTxt.autoSize = TextFieldAutoSize.LEFT;
			_titleTxt.antiAliasType = AntiAliasType.ADVANCED;
			_bg.addChild(_titleTxt);
			_titleTxt.text = "";
		}
		
		// Public Function
		public function hide():void{
//			Tweener.addTween(_bg, {y:HEIGHT, time:0.6, transition:"easeOutQuint"});
			TweenLite.to(_bg, 0.6, {y:HEIGHT});
		}
		
		public function show():void{
//			Tweener.addTween(_bg, {y:0, time:0.6, transition:"easeOutQuint"});
			TweenLite.to(_bg, 0.6, {y:0});
		}
		
		public function Dispose():void{
//			Tweener.removeTweens(this);
			removeAllChilds();
		}
		
		// Get and Set
		public function set title(value:String):void{
			_titleTxt.text = value;
		}
		
	}
}